package com.bondar.interfaces;

import java.util.Iterator;

public interface MyMap<Key> {
	/**
	 * Removes all of the mappings from this map
	 */
	void clear();

	/**
	 * Returns true if this map contains a mapping for the specified key
	 * 
	 * @param key
	 * @return true if this map contains a mapping for the specified key
	 */
	boolean containsKey(Key key);

	/**
	 * Returns true if this map maps one or more keys to the specified value
	 * 
	 * @param value
	 * @return true if this map maps one or more keys to the specified value
	 */
	boolean containsValue(Object value);

	/**
	 * Returns the value to which the specified key is mapped, <br>
	 * or null if this map contains no mapping for the key
	 * 
	 * @param key
	 * @return value to which the specified key is mapped<br>
	 *         or null if this map contains no mapping for the key
	 */
	Object get(Key key);

	/**
	 * Returns true if this map contains no key-value mappings
	 * 
	 * @return true if this map contains no key-value mappings
	 */
	boolean isEmpty();

	/**
	 * Associates the specified value with the specified key in this map
	 * 
	 * @param key
	 * @param value
	 * @return
	 */
	Object put(Key key, Object value);

	/**
	 * Removes the mapping for the specified key from this map if present
	 * 
	 * @param key
	 * @return the mapping for the specified key from this map if present
	 */
	Object remove(Key key);

	/**
	 * Returns the number of key-value mappings in this map
	 * 
	 * @return number of key-value mappings in this map
	 */
	int size();

	/**
	 * Returns an iterator over the elements (MyMap.Entry) in proper sequence
	 * 
	 * @return an iterator over the elements
	 */
	@SuppressWarnings("rawtypes")
	Iterator entryIterator();

	interface Entry<Key> {
		/**
		 * Compares the specified object with this entry for equality
		 * 
		 * @param o
		 * @return
		 */
		boolean equals(Object o);

		/**
		 * Returns the key corresponding to this entry
		 * 
		 * @return key corresponding to this entry
		 */
		Object getKey();

		/**
		 * Returns the value corresponding to this entry
		 * 
		 * @return value corresponding to this entry
		 */
		Object getValue();

		/**
		 * Returns the hash code value for this map entry
		 * 
		 * @return hash code value for this map entry
		 */
		int hashCode();

		/**
		 * Replaces the value corresponding to this entry with the specified
		 * value
		 * 
		 * @param value
		 * @return value corresponding to this entry with the specified value
		 */
		Object setValue(Object value);
	}

}
